<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>
  Class: Jammit::Packager
  
    &mdash; Jammit
  
</title>

  <link rel="stylesheet" href="../css/style.css" type="text/css" charset="utf-8" />

  <link rel="stylesheet" href="../css/common.css" type="text/css" charset="utf-8" />

<script type="text/javascript" charset="utf-8">
  hasFrames = window.top.frames.main ? true : false;
  relpath = '../';
  framesUrl = "../frames.html#!Jammit/Packager.html";
</script>


  <script type="text/javascript" charset="utf-8" src="../js/jquery.js"></script>

  <script type="text/javascript" charset="utf-8" src="../js/app.js"></script>


  </head>
  <body>
    <div id="header">
      <div id="menu">
  
    <a href="../_index.html">Index (P)</a> &raquo;
    <span class='title'><span class='object_link'><a href="../Jammit.html" title="Jammit (module)">Jammit</a></span></span>
     &raquo; 
    <span class="title">Packager</span>
  

  <div class="noframes"><span class="title">(</span><a href="." target="_top">no frames</a><span class="title">)</span></div>
</div>

      <div id="search">
  
    <a class="full_list_link" id="class_list_link"
        href="../class_list.html">
      Class List
    </a>
  
    <a class="full_list_link" id="method_list_link"
        href="../method_list.html">
      Method List
    </a>
  
    <a class="full_list_link" id="file_list_link"
        href="../file_list.html">
      File List
    </a>
  
</div>
      <div class="clear"></div>
    </div>

    <iframe id="search_frame"></iframe>

    <div id="content"><h1>Class: Jammit::Packager
  
  
  
</h1>

<dl class="box">
  
    <dt class="r1">Inherits:</dt>
    <dd class="r1">
      <span class="inheritName">Object</span>
      
        <ul class="fullTree">
          <li>Object</li>
          
            <li class="next">Jammit::Packager</li>
          
        </ul>
        <a href="#" class="inheritanceTree">show all</a>
      
      </dd>
    
  
  
    
  
    
  
  
  
    <dt class="r2 last">Defined in:</dt>
    <dd class="r2 last">lib/jammit/packager.rb</dd>
  
</dl>
<div class="clear"></div>

<h2>Overview</h2><div class="docstring">
  <div class="discussion">
    <p>The Jammit::Packager resolves the configuration file into lists of real
assets that get merged into individual asset packages. Given the compiled
contents of an asset package, the Packager knows how to cache that package
with the correct timestamps.</p>

  </div>
</div>
<div class="tags">
  

</div>



  <h2>Instance Attribute Summary <small>(<a href="#" class="summary_toggle">collapse</a>)</small></h2>
  <ul class="summary">
    
      <li class="public ">
  <span class="summary_signature">
    
      <a href="#force-instance_method" title="#force (instance method)">- (Object) <strong>force</strong> </a>
    

    
  </span>
  
  
  
    
    
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'><p>Set force to false to allow packages to only be rebuilt when their source files have changed since the last time their package was built.</p></div></span>
  
</li>

    
      <li class="public ">
  <span class="summary_signature">
    
      <a href="#package_names-instance_method" title="#package_names (instance method)">- (Object) <strong>package_names</strong> </a>
    

    
  </span>
  
  
  
    
    
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'><p>Set force to false to allow packages to only be rebuilt when their source files have changed since the last time their package was built.</p></div></span>
  
</li>

    
  </ul>




  
    <h2>
      Instance Method Summary
      <small>(<a href="#" class="summary_toggle">collapse</a>)</small>
    </h2>

    <ul class="summary">
      
        <li class="public ">
  <span class="summary_signature">
    
      <a href="#cache-instance_method" title="#cache (instance method)">- (Object) <strong>cache</strong>(package, extension, contents, output_dir, suffix = nil, mtime = nil) </a>
    

    
  </span>
  
  
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'><p>Caches a single prebuilt asset package and gzips it at the highest compression level.</p></div></span>
  
</li>

      
        <li class="private ">
  <span class="summary_signature">
    
      <a href="#cacheable-instance_method" title="#cacheable (instance method)">- (Object) <strong>cacheable</strong>(extension, output_dir) </a>
    

    
  </span>
  
  
  
  <span class="note title private">private</span>
  
  
  

  
    <span class="summary_desc"><div class='inline'><p>Return a list of all of the packages that should be cached.</p></div></span>
  
</li>

      
        <li class="public ">
  <span class="summary_signature">
    
      <a href="#compressor-instance_method" title="#compressor (instance method)">- (Object) <strong>compressor</strong> </a>
    

    
  </span>
  
  
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'></div></span>
  
</li>

      
        <li class="private ">
  <span class="summary_signature">
    
      <a href="#create_packages-instance_method" title="#create_packages (instance method)">- (Object) <strong>create_packages</strong>(config) </a>
    

    
  </span>
  
  
  
  <span class="note title private">private</span>
  
  
  

  
    <span class="summary_desc"><div class='inline'><p>Compiles the list of assets that goes into each package.</p></div></span>
  
</li>

      
        <li class="private ">
  <span class="summary_signature">
    
      <a href="#glob_files-instance_method" title="#glob_files (instance method)">- (Object) <strong>glob_files</strong>(glob) </a>
    

    
  </span>
  
  
  
  <span class="note title private">private</span>
  
  
  

  
    <span class="summary_desc"><div class='inline'><p>Absolute globs are absolute &#8212; relative globs are relative to ASSET_ROOT.</p></div></span>
  
</li>

      
        <li class="public ">
  <span class="summary_signature">
    
      <a href="#individual_urls-instance_method" title="#individual_urls (instance method)">- (Object) <strong>individual_urls</strong>(package, extension) </a>
    

    
  </span>
  
  
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'><p>Get the list of individual assets for a package.</p></div></span>
  
</li>

      
        <li class="public ">
  <span class="summary_signature">
    
      <a href="#initialize-instance_method" title="#initialize (instance method)">- (Packager) <strong>initialize</strong> </a>
    

    
  </span>
  
  
    <span class="note title constructor">constructor</span>
  
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'><p>Creating a new Packager will rebuild the list of assets from the Jammit.configuration.</p></div></span>
  
</li>

      
        <li class="private ">
  <span class="summary_signature">
    
      <a href="#latest_mtime-instance_method" title="#latest_mtime (instance method)">- (Object) <strong>latest_mtime</strong>(paths) </a>
    

    
  </span>
  
  
  
  <span class="note title private">private</span>
  
  
  

  
    <span class="summary_desc"><div class='inline'><p>Get the latest mtime of a list of files (plus the config path).</p></div></span>
  
</li>

      
        <li class="private ">
  <span class="summary_signature">
    
      <a href="#not_found-instance_method" title="#not_found (instance method)">- (Object) <strong>not_found</strong>(package, extension) </a>
    

    
  </span>
  
  
  
  <span class="note title private">private</span>
  
  
  

  
    <span class="summary_desc"><div class='inline'><p>Raise a PackageNotFound exception for missing packages&#8230;</p></div></span>
  
</li>

      
        <li class="public ">
  <span class="summary_signature">
    
      <a href="#pack_javascripts-instance_method" title="#pack_javascripts (instance method)">- (Object) <strong>pack_javascripts</strong>(package) </a>
    

    
  </span>
  
  
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'><p>Return the compressed contents of a javascript package.</p></div></span>
  
</li>

      
        <li class="public ">
  <span class="summary_signature">
    
      <a href="#pack_stylesheets-instance_method" title="#pack_stylesheets (instance method)">- (Object) <strong>pack_stylesheets</strong>(package, variant = nil, asset_url = nil) </a>
    

    
  </span>
  
  
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'><p>Return the compressed contents of a stylesheet package.</p></div></span>
  
</li>

      
        <li class="public ">
  <span class="summary_signature">
    
      <a href="#pack_templates-instance_method" title="#pack_templates (instance method)">- (Object) <strong>pack_templates</strong>(package) </a>
    

    
  </span>
  
  
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'><p>Return the compiled contents of a <span class="caps">JST</span> package.</p></div></span>
  
</li>

      
        <li class="private ">
  <span class="summary_signature">
    
      <a href="#package_for-instance_method" title="#package_for (instance method)">- (Object) <strong>package_for</strong>(package, extension) </a>
    

    
  </span>
  
  
  
  <span class="note title private">private</span>
  
  
  

  
    <span class="summary_desc"><div class='inline'><p>Look up a package asset list by name, raising an exception if the package has gone missing.</p></div></span>
  
</li>

      
        <li class="private ">
  <span class="summary_signature">
    
      <a href="#path_to_url-instance_method" title="#path_to_url (instance method)">- (Object) <strong>path_to_url</strong> </a>
    

    
  </span>
  
  
  
  <span class="note title private">private</span>
  
  
  

  
    <span class="summary_desc"><div class='inline'><p>In Rails, the difference between a path and an asset <span class="caps">URL</span> is &#8220;public&#8221;.</p></div></span>
  
</li>

      
        <li class="public ">
  <span class="summary_signature">
    
      <a href="#precache_all-instance_method" title="#precache_all (instance method)">- (Object) <strong>precache_all</strong>(output_dir = nil, base_url = nil) </a>
    

    
  </span>
  
  
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'><p>Ask the packager to precache all defined assets, along with their gzip&#8217;d versions.</p></div></span>
  
</li>

      
    </ul>
  

<div id="constructor_details" class="method_details_list">
  <h2>Constructor Details</h2>
  
    <div class="method_details first">
  <h3 class="signature first" id="initialize-instance_method">
  
    - (<tt><span class='object_link'><a href="" title="Jammit::Packager (class)">Packager</a></span></tt>) <strong>initialize</strong> 
  

  

  
</h3><div class="docstring">
  <div class="discussion">
    <p>Creating a new Packager will rebuild the list of assets from the
Jammit.configuration. When assets.yml is being changed on the fly,
create a new Packager.</p>

  </div>
</div>
<div class="tags">
  

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


16
17
18
19
20
21
22
23
24
25
26
27</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'lib/jammit/packager.rb', line 16</span>

<span class='kw'>def</span> <span class='id identifier rubyid_initialize'>initialize</span>
  <span class='ivar'>@force</span>          <span class='op'>=</span> <span class='kw'>false</span>
  <span class='ivar'>@package_names</span>  <span class='op'>=</span> <span class='kw'>nil</span>
  <span class='ivar'>@config</span> <span class='op'>=</span> <span class='lbrace'>{</span>
    <span class='symbol'>:css</span> <span class='op'>=&gt;</span> <span class='lparen'>(</span><span class='const'>Jammit</span><span class='period'>.</span><span class='id identifier rubyid_configuration'>configuration</span><span class='lbracket'>[</span><span class='symbol'>:stylesheets</span><span class='rbracket'>]</span> <span class='op'>||</span> <span class='lbrace'>{</span><span class='rbrace'>}</span><span class='rparen'>)</span><span class='comma'>,</span>
    <span class='symbol'>:js</span>  <span class='op'>=&gt;</span> <span class='lparen'>(</span><span class='const'>Jammit</span><span class='period'>.</span><span class='id identifier rubyid_configuration'>configuration</span><span class='lbracket'>[</span><span class='symbol'>:javascripts</span><span class='rbracket'>]</span> <span class='op'>||</span> <span class='lbrace'>{</span><span class='rbrace'>}</span><span class='rparen'>)</span>
  <span class='rbrace'>}</span>
  <span class='ivar'>@packages</span> <span class='op'>=</span> <span class='lbrace'>{</span>
    <span class='symbol'>:css</span> <span class='op'>=&gt;</span> <span class='id identifier rubyid_create_packages'>create_packages</span><span class='lparen'>(</span><span class='ivar'>@config</span><span class='lbracket'>[</span><span class='symbol'>:css</span><span class='rbracket'>]</span><span class='rparen'>)</span><span class='comma'>,</span>
    <span class='symbol'>:js</span>  <span class='op'>=&gt;</span> <span class='id identifier rubyid_create_packages'>create_packages</span><span class='lparen'>(</span><span class='ivar'>@config</span><span class='lbracket'>[</span><span class='symbol'>:js</span><span class='rbracket'>]</span><span class='rparen'>)</span>
  <span class='rbrace'>}</span>
<span class='kw'>end</span></pre>
    </td>
  </tr>
</table>
</div>
  
</div>

  <div id="instance_attr_details" class="attr_details">
    <h2>Instance Attribute Details</h2>
    
      
      <span id="force=-instance_method"></span>
      <div class="method_details first">
  <h3 class="signature first" id="force-instance_method">
  
    - (<tt>Object</tt>) <strong>force</strong> 
  

  

  
</h3><div class="docstring">
  <div class="discussion">
    <p>Set force to false to allow packages to only be rebuilt when their source
files have changed since the last time their package was built.</p>

  </div>
</div>
<div class="tags">
  

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


11
12
13</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'lib/jammit/packager.rb', line 11</span>

<span class='kw'>def</span> <span class='id identifier rubyid_force'>force</span>
  <span class='ivar'>@force</span>
<span class='kw'>end</span></pre>
    </td>
  </tr>
</table>
</div>
    
      
      <span id="package_names=-instance_method"></span>
      <div class="method_details ">
  <h3 class="signature " id="package_names-instance_method">
  
    - (<tt>Object</tt>) <strong>package_names</strong> 
  

  

  
</h3><div class="docstring">
  <div class="discussion">
    <p>Set force to false to allow packages to only be rebuilt when their source
files have changed since the last time their package was built.</p>

  </div>
</div>
<div class="tags">
  

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


11
12
13</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'lib/jammit/packager.rb', line 11</span>

<span class='kw'>def</span> <span class='id identifier rubyid_package_names'>package_names</span>
  <span class='ivar'>@package_names</span>
<span class='kw'>end</span></pre>
    </td>
  </tr>
</table>
</div>
    
  </div>


  <div id="instance_method_details" class="method_details_list">
    <h2>Instance Method Details</h2>

    
      <div class="method_details first">
  <h3 class="signature first" id="cache-instance_method">
  
    - (<tt>Object</tt>) <strong>cache</strong>(package, extension, contents, output_dir, suffix = nil, mtime = nil) 
  

  

  
</h3><div class="docstring">
  <div class="discussion">
    <p>Caches a single prebuilt asset package and gzips it at the highest
compression level. Ensures that the modification time of both both
variants is identical, for web server caching modules, as well as <span class="caps">MHTML</span>.</p>

  </div>
</div>
<div class="tags">
  
<p class="tag_title">Raises:</p>
<ul class="raise">
  
    <li>
      
      
        <span class='type'>(<tt><span class='object_link'><a href="OutputNotWritable.html" title="Jammit::OutputNotWritable (class)">OutputNotWritable</a></span></tt>)</span>
      
      
      
    </li>
  
</ul>

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


54
55
56
57
58
59
60
61
62
63
64
65
66</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'lib/jammit/packager.rb', line 54</span>

<span class='kw'>def</span> <span class='id identifier rubyid_cache'>cache</span><span class='lparen'>(</span><span class='id identifier rubyid_package'>package</span><span class='comma'>,</span> <span class='id identifier rubyid_extension'>extension</span><span class='comma'>,</span> <span class='id identifier rubyid_contents'>contents</span><span class='comma'>,</span> <span class='id identifier rubyid_output_dir'>output_dir</span><span class='comma'>,</span> <span class='id identifier rubyid_suffix'>suffix</span><span class='op'>=</span><span class='kw'>nil</span><span class='comma'>,</span> <span class='id identifier rubyid_mtime'>mtime</span><span class='op'>=</span><span class='kw'>nil</span><span class='rparen'>)</span>
  <span class='const'>FileUtils</span><span class='period'>.</span><span class='id identifier rubyid_mkdir_p'>mkdir_p</span><span class='lparen'>(</span><span class='id identifier rubyid_output_dir'>output_dir</span><span class='rparen'>)</span> <span class='kw'>unless</span> <span class='const'>File</span><span class='period'>.</span><span class='id identifier rubyid_exists?'>exists?</span><span class='lparen'>(</span><span class='id identifier rubyid_output_dir'>output_dir</span><span class='rparen'>)</span>
  <span class='id identifier rubyid_raise'>raise</span> <span class='const'>OutputNotWritable</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Jammit doesn&#39;t have permission to write to \&quot;</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_output_dir'>output_dir</span><span class='embexpr_end'>}</span><span class='tstring_content'>\&quot;</span><span class='tstring_end'>&quot;</span></span> <span class='kw'>unless</span> <span class='const'>File</span><span class='period'>.</span><span class='id identifier rubyid_writable?'>writable?</span><span class='lparen'>(</span><span class='id identifier rubyid_output_dir'>output_dir</span><span class='rparen'>)</span>
  <span class='id identifier rubyid_mtime'>mtime</span> <span class='op'>||=</span> <span class='id identifier rubyid_latest_mtime'>latest_mtime</span> <span class='id identifier rubyid_package_for'>package_for</span><span class='lparen'>(</span><span class='id identifier rubyid_package'>package</span><span class='comma'>,</span> <span class='id identifier rubyid_extension'>extension</span><span class='period'>.</span><span class='id identifier rubyid_to_sym'>to_sym</span><span class='rparen'>)</span><span class='lbracket'>[</span><span class='symbol'>:paths</span><span class='rbracket'>]</span>
  <span class='id identifier rubyid_files'>files</span> <span class='op'>=</span> <span class='lbracket'>[</span><span class='rbracket'>]</span>
  <span class='id identifier rubyid_files'>files</span> <span class='op'>&lt;&lt;</span> <span class='id identifier rubyid_file_name'>file_name</span> <span class='op'>=</span> <span class='const'>File</span><span class='period'>.</span><span class='id identifier rubyid_join'>join</span><span class='lparen'>(</span><span class='id identifier rubyid_output_dir'>output_dir</span><span class='comma'>,</span> <span class='const'>Jammit</span><span class='period'>.</span><span class='id identifier rubyid_filename'>filename</span><span class='lparen'>(</span><span class='id identifier rubyid_package'>package</span><span class='comma'>,</span> <span class='id identifier rubyid_extension'>extension</span><span class='comma'>,</span> <span class='id identifier rubyid_suffix'>suffix</span><span class='rparen'>)</span><span class='rparen'>)</span>
  <span class='const'>File</span><span class='period'>.</span><span class='id identifier rubyid_open'>open</span><span class='lparen'>(</span><span class='id identifier rubyid_file_name'>file_name</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>wb+</span><span class='tstring_end'>&#39;</span></span><span class='rparen'>)</span> <span class='lbrace'>{</span><span class='op'>|</span><span class='id identifier rubyid_f'>f</span><span class='op'>|</span> <span class='id identifier rubyid_f'>f</span><span class='period'>.</span><span class='id identifier rubyid_write'>write</span><span class='lparen'>(</span><span class='id identifier rubyid_contents'>contents</span><span class='rparen'>)</span> <span class='rbrace'>}</span>
  <span class='kw'>if</span> <span class='const'>Jammit</span><span class='period'>.</span><span class='id identifier rubyid_gzip_assets'>gzip_assets</span>
    <span class='id identifier rubyid_files'>files</span> <span class='op'>&lt;&lt;</span> <span class='id identifier rubyid_zip_name'>zip_name</span> <span class='op'>=</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_file_name'>file_name</span><span class='embexpr_end'>}</span><span class='tstring_content'>.gz</span><span class='tstring_end'>&quot;</span></span>
    <span class='const'>Zlib</span><span class='op'>::</span><span class='const'>GzipWriter</span><span class='period'>.</span><span class='id identifier rubyid_open'>open</span><span class='lparen'>(</span><span class='id identifier rubyid_zip_name'>zip_name</span><span class='comma'>,</span> <span class='const'>Zlib</span><span class='op'>::</span><span class='const'>BEST_COMPRESSION</span><span class='rparen'>)</span> <span class='lbrace'>{</span><span class='op'>|</span><span class='id identifier rubyid_f'>f</span><span class='op'>|</span> <span class='id identifier rubyid_f'>f</span><span class='period'>.</span><span class='id identifier rubyid_write'>write</span><span class='lparen'>(</span><span class='id identifier rubyid_contents'>contents</span><span class='rparen'>)</span> <span class='rbrace'>}</span>
  <span class='kw'>end</span>
  <span class='const'>File</span><span class='period'>.</span><span class='id identifier rubyid_utime'>utime</span><span class='lparen'>(</span><span class='id identifier rubyid_mtime'>mtime</span><span class='comma'>,</span> <span class='id identifier rubyid_mtime'>mtime</span><span class='comma'>,</span> <span class='op'>*</span><span class='id identifier rubyid_files'>files</span><span class='rparen'>)</span>
<span class='kw'>end</span></pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <h3 class="signature " id="cacheable-instance_method">
  
    - (<tt>Object</tt>) <strong>cacheable</strong>(extension, output_dir)  <span class="extras">(private)</span>
  

  

  
</h3><div class="docstring">
  <div class="discussion">
    <p>Return a list of all of the packages that should be cached. If &#8220;force&#8221; is
true, this is all of them &#8212; otherwise only the packages that are missing
or whose source files have changed since the last package build.</p>

  </div>
</div>
<div class="tags">
  

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'lib/jammit/packager.rb', line 125</span>

<span class='kw'>def</span> <span class='id identifier rubyid_cacheable'>cacheable</span><span class='lparen'>(</span><span class='id identifier rubyid_extension'>extension</span><span class='comma'>,</span> <span class='id identifier rubyid_output_dir'>output_dir</span><span class='rparen'>)</span>
  <span class='id identifier rubyid_names'>names</span> <span class='op'>=</span> <span class='ivar'>@packages</span><span class='lbracket'>[</span><span class='id identifier rubyid_extension'>extension</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_keys'>keys</span>
  <span class='id identifier rubyid_names'>names</span> <span class='op'>=</span> <span class='id identifier rubyid_names'>names</span><span class='period'>.</span><span class='id identifier rubyid_select'>select</span> <span class='lbrace'>{</span><span class='op'>|</span><span class='id identifier rubyid_n'>n</span><span class='op'>|</span> <span class='ivar'>@package_names</span><span class='period'>.</span><span class='id identifier rubyid_include?'>include?</span> <span class='id identifier rubyid_n'>n</span> <span class='rbrace'>}</span> <span class='kw'>if</span> <span class='ivar'>@package_names</span>
  <span class='id identifier rubyid_config_mtime'>config_mtime</span> <span class='op'>=</span> <span class='const'>File</span><span class='period'>.</span><span class='id identifier rubyid_mtime'>mtime</span><span class='lparen'>(</span><span class='const'>Jammit</span><span class='period'>.</span><span class='id identifier rubyid_config_path'>config_path</span><span class='rparen'>)</span>
  <span class='kw'>return</span> <span class='id identifier rubyid_names'>names</span> <span class='kw'>if</span> <span class='ivar'>@force</span>
  <span class='kw'>return</span> <span class='id identifier rubyid_names'>names</span><span class='period'>.</span><span class='id identifier rubyid_select'>select</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_name'>name</span><span class='op'>|</span>
    <span class='id identifier rubyid_pack'>pack</span>        <span class='op'>=</span> <span class='id identifier rubyid_package_for'>package_for</span><span class='lparen'>(</span><span class='id identifier rubyid_name'>name</span><span class='comma'>,</span> <span class='id identifier rubyid_extension'>extension</span><span class='rparen'>)</span>
    <span class='id identifier rubyid_cached'>cached</span>      <span class='op'>=</span> <span class='lbracket'>[</span><span class='const'>Jammit</span><span class='period'>.</span><span class='id identifier rubyid_filename'>filename</span><span class='lparen'>(</span><span class='id identifier rubyid_name'>name</span><span class='comma'>,</span> <span class='id identifier rubyid_extension'>extension</span><span class='rparen'>)</span><span class='rbracket'>]</span>
    <span class='kw'>if</span> <span class='id identifier rubyid_extension'>extension</span> <span class='op'>==</span> <span class='symbol'>:css</span>
      <span class='id identifier rubyid_cached'>cached</span><span class='period'>.</span><span class='id identifier rubyid_push'>push</span> <span class='const'>Jammit</span><span class='period'>.</span><span class='id identifier rubyid_filename'>filename</span><span class='lparen'>(</span><span class='id identifier rubyid_name'>name</span><span class='comma'>,</span> <span class='id identifier rubyid_extension'>extension</span><span class='comma'>,</span> <span class='symbol'>:datauri</span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='const'>Jammit</span><span class='period'>.</span><span class='id identifier rubyid_embed_assets'>embed_assets</span>
      <span class='id identifier rubyid_cached'>cached</span><span class='period'>.</span><span class='id identifier rubyid_push'>push</span> <span class='const'>Jammit</span><span class='period'>.</span><span class='id identifier rubyid_filename'>filename</span><span class='lparen'>(</span><span class='id identifier rubyid_name'>name</span><span class='comma'>,</span> <span class='id identifier rubyid_extension'>extension</span><span class='comma'>,</span> <span class='symbol'>:mhtml</span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='const'>Jammit</span><span class='period'>.</span><span class='id identifier rubyid_mhtml_enabled'>mhtml_enabled</span>
    <span class='kw'>end</span>
    <span class='id identifier rubyid_cached'>cached</span><span class='period'>.</span><span class='id identifier rubyid_map!'>map!</span> <span class='lbrace'>{</span><span class='op'>|</span><span class='id identifier rubyid_file'>file</span><span class='op'>|</span> <span class='const'>File</span><span class='period'>.</span><span class='id identifier rubyid_join'>join</span><span class='lparen'>(</span><span class='id identifier rubyid_output_dir'>output_dir</span><span class='comma'>,</span> <span class='id identifier rubyid_file'>file</span><span class='rparen'>)</span> <span class='rbrace'>}</span>
    <span class='kw'>if</span> <span class='id identifier rubyid_cached'>cached</span><span class='period'>.</span><span class='id identifier rubyid_any?'>any?</span> <span class='lbrace'>{</span><span class='op'>|</span><span class='id identifier rubyid_file'>file</span><span class='op'>|</span> <span class='op'>!</span><span class='const'>File</span><span class='period'>.</span><span class='id identifier rubyid_exists?'>exists?</span><span class='lparen'>(</span><span class='id identifier rubyid_file'>file</span><span class='rparen'>)</span> <span class='rbrace'>}</span>
      <span class='kw'>true</span>
    <span class='kw'>else</span>
      <span class='id identifier rubyid_since'>since</span> <span class='op'>=</span> <span class='id identifier rubyid_cached'>cached</span><span class='period'>.</span><span class='id identifier rubyid_map'>map</span> <span class='lbrace'>{</span><span class='op'>|</span><span class='id identifier rubyid_file'>file</span><span class='op'>|</span> <span class='const'>File</span><span class='period'>.</span><span class='id identifier rubyid_mtime'>mtime</span><span class='lparen'>(</span><span class='id identifier rubyid_file'>file</span><span class='rparen'>)</span> <span class='rbrace'>}</span><span class='period'>.</span><span class='id identifier rubyid_min'>min</span>
      <span class='id identifier rubyid_config_mtime'>config_mtime</span> <span class='op'>&gt;</span> <span class='id identifier rubyid_since'>since</span> <span class='op'>||</span> <span class='id identifier rubyid_pack'>pack</span><span class='lbracket'>[</span><span class='symbol'>:paths</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_any?'>any?</span> <span class='lbrace'>{</span><span class='op'>|</span><span class='id identifier rubyid_src'>src</span><span class='op'>|</span> <span class='const'>File</span><span class='period'>.</span><span class='id identifier rubyid_mtime'>mtime</span><span class='lparen'>(</span><span class='id identifier rubyid_src'>src</span><span class='rparen'>)</span> <span class='op'>&gt;</span> <span class='id identifier rubyid_since'>since</span> <span class='rbrace'>}</span>
    <span class='kw'>end</span>
  <span class='kw'>end</span>
<span class='kw'>end</span></pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <h3 class="signature " id="compressor-instance_method">
  
    - (<tt>Object</tt>) <strong>compressor</strong> 
  

  

  
</h3><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


73
74
75</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'lib/jammit/packager.rb', line 73</span>

<span class='kw'>def</span> <span class='id identifier rubyid_compressor'>compressor</span>
  <span class='ivar'>@compressor</span> <span class='op'>||=</span> <span class='const'>Compressor</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span>
<span class='kw'>end</span></pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <h3 class="signature " id="create_packages-instance_method">
  
    - (<tt>Object</tt>) <strong>create_packages</strong>(config)  <span class="extras">(private)</span>
  

  

  
</h3><div class="docstring">
  <div class="discussion">
    <p>Compiles the list of assets that goes into each package. Runs an
ordered list of Dir.globs, taking the merged unique result.
If there are <span class="caps">JST</span> files in this package we need to add an extra
path for when package_assets is off (e.g. in a dev environment).
This package (e.g. /assets/package-name.jst) will never exist as
an actual file but will be dynamically generated by Jammit on
every request.</p>

  </div>
</div>
<div class="tags">
  

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'lib/jammit/packager.rb', line 154</span>

<span class='kw'>def</span> <span class='id identifier rubyid_create_packages'>create_packages</span><span class='lparen'>(</span><span class='id identifier rubyid_config'>config</span><span class='rparen'>)</span>
  <span class='id identifier rubyid_packages'>packages</span> <span class='op'>=</span> <span class='lbrace'>{</span><span class='rbrace'>}</span>
  <span class='kw'>return</span> <span class='id identifier rubyid_packages'>packages</span> <span class='kw'>if</span> <span class='op'>!</span><span class='id identifier rubyid_config'>config</span>
  <span class='id identifier rubyid_config'>config</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_name'>name</span><span class='comma'>,</span> <span class='id identifier rubyid_globs'>globs</span><span class='op'>|</span>
    <span class='id identifier rubyid_globs'>globs</span>                  <span class='op'>||=</span> <span class='lbracket'>[</span><span class='rbracket'>]</span>
    <span class='id identifier rubyid_packages'>packages</span><span class='lbracket'>[</span><span class='id identifier rubyid_name'>name</span><span class='rbracket'>]</span>         <span class='op'>=</span> <span class='lbrace'>{</span><span class='rbrace'>}</span>
    <span class='id identifier rubyid_paths'>paths</span>                  <span class='op'>=</span> <span class='id identifier rubyid_globs'>globs</span><span class='period'>.</span><span class='id identifier rubyid_flatten'>flatten</span><span class='period'>.</span><span class='id identifier rubyid_uniq'>uniq</span><span class='period'>.</span><span class='id identifier rubyid_map'>map</span> <span class='lbrace'>{</span><span class='op'>|</span><span class='id identifier rubyid_glob'>glob</span><span class='op'>|</span> <span class='id identifier rubyid_glob_files'>glob_files</span><span class='lparen'>(</span><span class='id identifier rubyid_glob'>glob</span><span class='rparen'>)</span> <span class='rbrace'>}</span><span class='period'>.</span><span class='id identifier rubyid_flatten'>flatten</span><span class='period'>.</span><span class='id identifier rubyid_uniq'>uniq</span>
    <span class='id identifier rubyid_packages'>packages</span><span class='lbracket'>[</span><span class='id identifier rubyid_name'>name</span><span class='rbracket'>]</span><span class='lbracket'>[</span><span class='symbol'>:paths</span><span class='rbracket'>]</span> <span class='op'>=</span> <span class='id identifier rubyid_paths'>paths</span>
    <span class='kw'>if</span> <span class='op'>!</span><span class='id identifier rubyid_paths'>paths</span><span class='period'>.</span><span class='id identifier rubyid_grep'>grep</span><span class='lparen'>(</span><span class='const'>Jammit</span><span class='period'>.</span><span class='id identifier rubyid_template_extension_matcher'>template_extension_matcher</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_empty?'>empty?</span>
      <span class='id identifier rubyid_packages'>packages</span><span class='lbracket'>[</span><span class='id identifier rubyid_name'>name</span><span class='rbracket'>]</span><span class='lbracket'>[</span><span class='symbol'>:urls</span><span class='rbracket'>]</span> <span class='op'>=</span> <span class='id identifier rubyid_paths'>paths</span><span class='period'>.</span><span class='id identifier rubyid_grep'>grep</span><span class='lparen'>(</span><span class='const'>JS_EXTENSION</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_map'>map</span> <span class='lbrace'>{</span><span class='op'>|</span><span class='id identifier rubyid_path'>path</span><span class='op'>|</span> <span class='id identifier rubyid_path'>path</span><span class='period'>.</span><span class='id identifier rubyid_sub'>sub</span><span class='lparen'>(</span><span class='id identifier rubyid_path_to_url'>path_to_url</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_end'>&#39;</span></span><span class='rparen'>)</span> <span class='rbrace'>}</span>
      <span class='id identifier rubyid_packages'>packages</span><span class='lbracket'>[</span><span class='id identifier rubyid_name'>name</span><span class='rbracket'>]</span><span class='lbracket'>[</span><span class='symbol'>:urls</span><span class='rbracket'>]</span> <span class='op'>+=</span> <span class='lbracket'>[</span><span class='const'>Jammit</span><span class='period'>.</span><span class='id identifier rubyid_asset_url'>asset_url</span><span class='lparen'>(</span><span class='id identifier rubyid_name'>name</span><span class='comma'>,</span> <span class='const'>Jammit</span><span class='period'>.</span><span class='id identifier rubyid_template_extension'>template_extension</span><span class='rparen'>)</span><span class='rbracket'>]</span>
    <span class='kw'>else</span>
      <span class='id identifier rubyid_packages'>packages</span><span class='lbracket'>[</span><span class='id identifier rubyid_name'>name</span><span class='rbracket'>]</span><span class='lbracket'>[</span><span class='symbol'>:urls</span><span class='rbracket'>]</span> <span class='op'>=</span> <span class='id identifier rubyid_paths'>paths</span><span class='period'>.</span><span class='id identifier rubyid_map'>map</span> <span class='lbrace'>{</span><span class='op'>|</span><span class='id identifier rubyid_path'>path</span><span class='op'>|</span> <span class='id identifier rubyid_path'>path</span><span class='period'>.</span><span class='id identifier rubyid_sub'>sub</span><span class='lparen'>(</span><span class='id identifier rubyid_path_to_url'>path_to_url</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_end'>&#39;</span></span><span class='rparen'>)</span> <span class='rbrace'>}</span>
    <span class='kw'>end</span>
  <span class='kw'>end</span>
  <span class='id identifier rubyid_packages'>packages</span>
<span class='kw'>end</span></pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <h3 class="signature " id="glob_files-instance_method">
  
    - (<tt>Object</tt>) <strong>glob_files</strong>(glob)  <span class="extras">(private)</span>
  

  

  
</h3><div class="docstring">
  <div class="discussion">
    <p>Absolute globs are absolute &#8212; relative globs are relative to ASSET_ROOT.
Print a warning if no files were found that match the glob.</p>

  </div>
</div>
<div class="tags">
  

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


104
105
106
107
108
109</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'lib/jammit/packager.rb', line 104</span>

<span class='kw'>def</span> <span class='id identifier rubyid_glob_files'>glob_files</span><span class='lparen'>(</span><span class='id identifier rubyid_glob'>glob</span><span class='rparen'>)</span>
  <span class='id identifier rubyid_absolute'>absolute</span> <span class='op'>=</span> <span class='const'>Pathname</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='id identifier rubyid_glob'>glob</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_absolute?'>absolute?</span>
  <span class='id identifier rubyid_paths'>paths</span> <span class='op'>=</span> <span class='const'>Dir</span><span class='lbracket'>[</span><span class='id identifier rubyid_absolute'>absolute</span> <span class='op'>?</span> <span class='id identifier rubyid_glob'>glob</span> <span class='op'>:</span> <span class='const'>File</span><span class='period'>.</span><span class='id identifier rubyid_join'>join</span><span class='lparen'>(</span><span class='const'>ASSET_ROOT</span><span class='comma'>,</span> <span class='id identifier rubyid_glob'>glob</span><span class='rparen'>)</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_sort'>sort</span>
  <span class='const'>Jammit</span><span class='period'>.</span><span class='id identifier rubyid_warn'>warn</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>No assets match &#39;</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_glob'>glob</span><span class='embexpr_end'>}</span><span class='tstring_content'>&#39;</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='id identifier rubyid_paths'>paths</span><span class='period'>.</span><span class='id identifier rubyid_empty?'>empty?</span>
  <span class='id identifier rubyid_paths'>paths</span>
<span class='kw'>end</span></pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <h3 class="signature " id="individual_urls-instance_method">
  
    - (<tt>Object</tt>) <strong>individual_urls</strong>(package, extension) 
  

  

  
</h3><div class="docstring">
  <div class="discussion">
    <p>Get the list of individual assets for a package.</p>

  </div>
</div>
<div class="tags">
  

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


69
70
71</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'lib/jammit/packager.rb', line 69</span>

<span class='kw'>def</span> <span class='id identifier rubyid_individual_urls'>individual_urls</span><span class='lparen'>(</span><span class='id identifier rubyid_package'>package</span><span class='comma'>,</span> <span class='id identifier rubyid_extension'>extension</span><span class='rparen'>)</span>
  <span class='id identifier rubyid_package_for'>package_for</span><span class='lparen'>(</span><span class='id identifier rubyid_package'>package</span><span class='comma'>,</span> <span class='id identifier rubyid_extension'>extension</span><span class='rparen'>)</span><span class='lbracket'>[</span><span class='symbol'>:urls</span><span class='rbracket'>]</span>
<span class='kw'>end</span></pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <h3 class="signature " id="latest_mtime-instance_method">
  
    - (<tt>Object</tt>) <strong>latest_mtime</strong>(paths)  <span class="extras">(private)</span>
  

  

  
</h3><div class="docstring">
  <div class="discussion">
    <p>Get the latest mtime of a list of files (plus the config path).</p>

  </div>
</div>
<div class="tags">
  

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


117
118
119
120</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'lib/jammit/packager.rb', line 117</span>

<span class='kw'>def</span> <span class='id identifier rubyid_latest_mtime'>latest_mtime</span><span class='lparen'>(</span><span class='id identifier rubyid_paths'>paths</span><span class='rparen'>)</span>
  <span class='id identifier rubyid_paths'>paths</span> <span class='op'>+=</span> <span class='lbracket'>[</span><span class='const'>Jammit</span><span class='period'>.</span><span class='id identifier rubyid_config_path'>config_path</span><span class='rbracket'>]</span>
  <span class='id identifier rubyid_paths'>paths</span><span class='period'>.</span><span class='id identifier rubyid_map'>map</span> <span class='lbrace'>{</span><span class='op'>|</span><span class='id identifier rubyid_p'>p</span><span class='op'>|</span> <span class='const'>File</span><span class='period'>.</span><span class='id identifier rubyid_mtime'>mtime</span><span class='lparen'>(</span><span class='id identifier rubyid_p'>p</span><span class='rparen'>)</span> <span class='rbrace'>}</span><span class='period'>.</span><span class='id identifier rubyid_max'>max</span> <span class='op'>||</span> <span class='const'>Time</span><span class='period'>.</span><span class='id identifier rubyid_now'>now</span>
<span class='kw'>end</span></pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <h3 class="signature " id="not_found-instance_method">
  
    - (<tt>Object</tt>) <strong>not_found</strong>(package, extension)  <span class="extras">(private)</span>
  

  

  
</h3><div class="docstring">
  <div class="discussion">
    <p>Raise a PackageNotFound exception for missing packages&#8230;</p>

  </div>
</div>
<div class="tags">
  
<p class="tag_title">Raises:</p>
<ul class="raise">
  
    <li>
      
      
        <span class='type'>(<tt><span class='object_link'><a href="PackageNotFound.html" title="Jammit::PackageNotFound (class)">PackageNotFound</a></span></tt>)</span>
      
      
      
    </li>
  
</ul>

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


173
174
175</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'lib/jammit/packager.rb', line 173</span>

<span class='kw'>def</span> <span class='id identifier rubyid_not_found'>not_found</span><span class='lparen'>(</span><span class='id identifier rubyid_package'>package</span><span class='comma'>,</span> <span class='id identifier rubyid_extension'>extension</span><span class='rparen'>)</span>
  <span class='id identifier rubyid_raise'>raise</span> <span class='const'>PackageNotFound</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>assets.yml does not contain a \&quot;</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_package'>package</span><span class='embexpr_end'>}</span><span class='tstring_content'>\&quot; </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_extension'>extension</span><span class='period'>.</span><span class='id identifier rubyid_to_s'>to_s</span><span class='period'>.</span><span class='id identifier rubyid_upcase'>upcase</span><span class='embexpr_end'>}</span><span class='tstring_content'> package</span><span class='tstring_end'>&quot;</span></span>
<span class='kw'>end</span></pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <h3 class="signature " id="pack_javascripts-instance_method">
  
    - (<tt>Object</tt>) <strong>pack_javascripts</strong>(package) 
  

  

  
</h3><div class="docstring">
  <div class="discussion">
    <p>Return the compressed contents of a javascript package.</p>

  </div>
</div>
<div class="tags">
  

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


83
84
85</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'lib/jammit/packager.rb', line 83</span>

<span class='kw'>def</span> <span class='id identifier rubyid_pack_javascripts'>pack_javascripts</span><span class='lparen'>(</span><span class='id identifier rubyid_package'>package</span><span class='rparen'>)</span>
  <span class='id identifier rubyid_compressor'>compressor</span><span class='period'>.</span><span class='id identifier rubyid_compress_js'>compress_js</span><span class='lparen'>(</span><span class='id identifier rubyid_package_for'>package_for</span><span class='lparen'>(</span><span class='id identifier rubyid_package'>package</span><span class='comma'>,</span> <span class='symbol'>:js</span><span class='rparen'>)</span><span class='lbracket'>[</span><span class='symbol'>:paths</span><span class='rbracket'>]</span><span class='rparen'>)</span>
<span class='kw'>end</span></pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <h3 class="signature " id="pack_stylesheets-instance_method">
  
    - (<tt>Object</tt>) <strong>pack_stylesheets</strong>(package, variant = nil, asset_url = nil) 
  

  

  
</h3><div class="docstring">
  <div class="discussion">
    <p>Return the compressed contents of a stylesheet package.</p>

  </div>
</div>
<div class="tags">
  

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


78
79
80</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'lib/jammit/packager.rb', line 78</span>

<span class='kw'>def</span> <span class='id identifier rubyid_pack_stylesheets'>pack_stylesheets</span><span class='lparen'>(</span><span class='id identifier rubyid_package'>package</span><span class='comma'>,</span> <span class='id identifier rubyid_variant'>variant</span><span class='op'>=</span><span class='kw'>nil</span><span class='comma'>,</span> <span class='id identifier rubyid_asset_url'>asset_url</span><span class='op'>=</span><span class='kw'>nil</span><span class='rparen'>)</span>
  <span class='id identifier rubyid_compressor'>compressor</span><span class='period'>.</span><span class='id identifier rubyid_compress_css'>compress_css</span><span class='lparen'>(</span><span class='id identifier rubyid_package_for'>package_for</span><span class='lparen'>(</span><span class='id identifier rubyid_package'>package</span><span class='comma'>,</span> <span class='symbol'>:css</span><span class='rparen'>)</span><span class='lbracket'>[</span><span class='symbol'>:paths</span><span class='rbracket'>]</span><span class='comma'>,</span> <span class='id identifier rubyid_variant'>variant</span><span class='comma'>,</span> <span class='id identifier rubyid_asset_url'>asset_url</span><span class='rparen'>)</span>
<span class='kw'>end</span></pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <h3 class="signature " id="pack_templates-instance_method">
  
    - (<tt>Object</tt>) <strong>pack_templates</strong>(package) 
  

  

  
</h3><div class="docstring">
  <div class="discussion">
    <p>Return the compiled contents of a <span class="caps">JST</span> package.</p>

  </div>
</div>
<div class="tags">
  

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


88
89
90</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'lib/jammit/packager.rb', line 88</span>

<span class='kw'>def</span> <span class='id identifier rubyid_pack_templates'>pack_templates</span><span class='lparen'>(</span><span class='id identifier rubyid_package'>package</span><span class='rparen'>)</span>
  <span class='id identifier rubyid_compressor'>compressor</span><span class='period'>.</span><span class='id identifier rubyid_compile_jst'>compile_jst</span><span class='lparen'>(</span><span class='id identifier rubyid_package_for'>package_for</span><span class='lparen'>(</span><span class='id identifier rubyid_package'>package</span><span class='comma'>,</span> <span class='symbol'>:js</span><span class='rparen'>)</span><span class='lbracket'>[</span><span class='symbol'>:paths</span><span class='rbracket'>]</span><span class='rparen'>)</span>
<span class='kw'>end</span></pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <h3 class="signature " id="package_for-instance_method">
  
    - (<tt>Object</tt>) <strong>package_for</strong>(package, extension)  <span class="extras">(private)</span>
  

  

  
</h3><div class="docstring">
  <div class="discussion">
    <p>Look up a package asset list by name, raising an exception if the
package has gone missing.</p>

  </div>
</div>
<div class="tags">
  

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


97
98
99
100</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'lib/jammit/packager.rb', line 97</span>

<span class='kw'>def</span> <span class='id identifier rubyid_package_for'>package_for</span><span class='lparen'>(</span><span class='id identifier rubyid_package'>package</span><span class='comma'>,</span> <span class='id identifier rubyid_extension'>extension</span><span class='rparen'>)</span>
  <span class='id identifier rubyid_pack'>pack</span> <span class='op'>=</span> <span class='ivar'>@packages</span><span class='lbracket'>[</span><span class='id identifier rubyid_extension'>extension</span><span class='rbracket'>]</span> <span class='op'>&amp;&amp;</span> <span class='ivar'>@packages</span><span class='lbracket'>[</span><span class='id identifier rubyid_extension'>extension</span><span class='rbracket'>]</span><span class='lbracket'>[</span><span class='id identifier rubyid_package'>package</span><span class='rbracket'>]</span>
  <span class='id identifier rubyid_pack'>pack</span> <span class='op'>||</span> <span class='id identifier rubyid_not_found'>not_found</span><span class='lparen'>(</span><span class='id identifier rubyid_package'>package</span><span class='comma'>,</span> <span class='id identifier rubyid_extension'>extension</span><span class='rparen'>)</span>
<span class='kw'>end</span></pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <h3 class="signature " id="path_to_url-instance_method">
  
    - (<tt>Object</tt>) <strong>path_to_url</strong>  <span class="extras">(private)</span>
  

  

  
</h3><div class="docstring">
  <div class="discussion">
    <p>In Rails, the difference between a path and an asset <span class="caps">URL</span> is &#8220;public&#8221;.</p>

  </div>
</div>
<div class="tags">
  

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


112
113
114</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'lib/jammit/packager.rb', line 112</span>

<span class='kw'>def</span> <span class='id identifier rubyid_path_to_url'>path_to_url</span>
  <span class='ivar'>@path_to_url</span> <span class='op'>||=</span> <span class='tstring'><span class='regexp_beg'>/</span><span class='tstring_content'>\A</span><span class='embexpr_beg'>#{</span><span class='const'>Regexp</span><span class='period'>.</span><span class='id identifier rubyid_escape'>escape</span><span class='lparen'>(</span><span class='const'>ASSET_ROOT</span><span class='rparen'>)</span><span class='embexpr_end'>}</span><span class='tstring_content'>(\/?</span><span class='embexpr_beg'>#{</span><span class='const'>Regexp</span><span class='period'>.</span><span class='id identifier rubyid_escape'>escape</span><span class='lparen'>(</span><span class='const'>Jammit</span><span class='period'>.</span><span class='id identifier rubyid_public_root'>public_root</span><span class='period'>.</span><span class='id identifier rubyid_sub'>sub</span><span class='lparen'>(</span><span class='const'>ASSET_ROOT</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_end'>&#39;</span></span><span class='rparen'>)</span><span class='rparen'>)</span><span class='embexpr_end'>}</span><span class='tstring_content'>)?</span><span class='regexp_end'>/</span></span>
<span class='kw'>end</span></pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <h3 class="signature " id="precache_all-instance_method">
  
    - (<tt>Object</tt>) <strong>precache_all</strong>(output_dir = nil, base_url = nil) 
  

  

  
</h3><div class="docstring">
  <div class="discussion">
    <p>Ask the packager to precache all defined assets, along with their gzip&#8217;d
versions. In order to prebuild the <span class="caps">MHTML</span> stylesheets, we need to know the
base_url, because IE only supports <span class="caps">MHTML</span> with absolute references.
Unless forced, will only rebuild assets whose source files have been
changed since their last package build.</p>

  </div>
</div>
<div class="tags">
  

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'lib/jammit/packager.rb', line 34</span>

<span class='kw'>def</span> <span class='id identifier rubyid_precache_all'>precache_all</span><span class='lparen'>(</span><span class='id identifier rubyid_output_dir'>output_dir</span><span class='op'>=</span><span class='kw'>nil</span><span class='comma'>,</span> <span class='id identifier rubyid_base_url'>base_url</span><span class='op'>=</span><span class='kw'>nil</span><span class='rparen'>)</span>
  <span class='id identifier rubyid_output_dir'>output_dir</span> <span class='op'>||=</span> <span class='const'>File</span><span class='period'>.</span><span class='id identifier rubyid_join'>join</span><span class='lparen'>(</span><span class='const'>Jammit</span><span class='period'>.</span><span class='id identifier rubyid_public_root'>public_root</span><span class='comma'>,</span> <span class='const'>Jammit</span><span class='period'>.</span><span class='id identifier rubyid_package_path'>package_path</span><span class='rparen'>)</span>
  <span class='id identifier rubyid_cacheable'>cacheable</span><span class='lparen'>(</span><span class='symbol'>:js</span><span class='comma'>,</span> <span class='id identifier rubyid_output_dir'>output_dir</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span>  <span class='lbrace'>{</span><span class='op'>|</span><span class='id identifier rubyid_p'>p</span><span class='op'>|</span> <span class='id identifier rubyid_cache'>cache</span><span class='lparen'>(</span><span class='id identifier rubyid_p'>p</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>js</span><span class='tstring_end'>&#39;</span></span><span class='comma'>,</span>  <span class='id identifier rubyid_pack_javascripts'>pack_javascripts</span><span class='lparen'>(</span><span class='id identifier rubyid_p'>p</span><span class='rparen'>)</span><span class='comma'>,</span> <span class='id identifier rubyid_output_dir'>output_dir</span><span class='rparen'>)</span> <span class='rbrace'>}</span>
  <span class='id identifier rubyid_cacheable'>cacheable</span><span class='lparen'>(</span><span class='symbol'>:css</span><span class='comma'>,</span> <span class='id identifier rubyid_output_dir'>output_dir</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_p'>p</span><span class='op'>|</span>
    <span class='id identifier rubyid_cache'>cache</span><span class='lparen'>(</span><span class='id identifier rubyid_p'>p</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>css</span><span class='tstring_end'>&#39;</span></span><span class='comma'>,</span> <span class='id identifier rubyid_pack_stylesheets'>pack_stylesheets</span><span class='lparen'>(</span><span class='id identifier rubyid_p'>p</span><span class='rparen'>)</span><span class='comma'>,</span> <span class='id identifier rubyid_output_dir'>output_dir</span><span class='rparen'>)</span>
    <span class='kw'>if</span> <span class='const'>Jammit</span><span class='period'>.</span><span class='id identifier rubyid_embed_assets'>embed_assets</span>
      <span class='id identifier rubyid_cache'>cache</span><span class='lparen'>(</span><span class='id identifier rubyid_p'>p</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>css</span><span class='tstring_end'>&#39;</span></span><span class='comma'>,</span> <span class='id identifier rubyid_pack_stylesheets'>pack_stylesheets</span><span class='lparen'>(</span><span class='id identifier rubyid_p'>p</span><span class='comma'>,</span> <span class='symbol'>:datauri</span><span class='rparen'>)</span><span class='comma'>,</span> <span class='id identifier rubyid_output_dir'>output_dir</span><span class='comma'>,</span> <span class='symbol'>:datauri</span><span class='rparen'>)</span>
      <span class='kw'>if</span> <span class='const'>Jammit</span><span class='period'>.</span><span class='id identifier rubyid_mhtml_enabled'>mhtml_enabled</span>
        <span class='id identifier rubyid_raise'>raise</span> <span class='const'>MissingConfiguration</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>A --base-url option is required in order to generate MHTML.</span><span class='tstring_end'>&quot;</span></span> <span class='kw'>unless</span> <span class='id identifier rubyid_base_url'>base_url</span>
        <span class='id identifier rubyid_mtime'>mtime</span> <span class='op'>=</span> <span class='id identifier rubyid_latest_mtime'>latest_mtime</span> <span class='id identifier rubyid_package_for'>package_for</span><span class='lparen'>(</span><span class='id identifier rubyid_p'>p</span><span class='comma'>,</span> <span class='symbol'>:css</span><span class='rparen'>)</span><span class='lbracket'>[</span><span class='symbol'>:paths</span><span class='rbracket'>]</span>
        <span class='id identifier rubyid_asset_url'>asset_url</span> <span class='op'>=</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_base_url'>base_url</span><span class='embexpr_end'>}</span><span class='embexpr_beg'>#{</span><span class='const'>Jammit</span><span class='period'>.</span><span class='id identifier rubyid_asset_url'>asset_url</span><span class='lparen'>(</span><span class='id identifier rubyid_p'>p</span><span class='comma'>,</span> <span class='symbol'>:css</span><span class='comma'>,</span> <span class='symbol'>:mhtml</span><span class='comma'>,</span> <span class='id identifier rubyid_mtime'>mtime</span><span class='rparen'>)</span><span class='embexpr_end'>}</span><span class='tstring_end'>&quot;</span></span>
        <span class='id identifier rubyid_cache'>cache</span><span class='lparen'>(</span><span class='id identifier rubyid_p'>p</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>css</span><span class='tstring_end'>&#39;</span></span><span class='comma'>,</span> <span class='id identifier rubyid_pack_stylesheets'>pack_stylesheets</span><span class='lparen'>(</span><span class='id identifier rubyid_p'>p</span><span class='comma'>,</span> <span class='symbol'>:mhtml</span><span class='comma'>,</span> <span class='id identifier rubyid_asset_url'>asset_url</span><span class='rparen'>)</span><span class='comma'>,</span> <span class='id identifier rubyid_output_dir'>output_dir</span><span class='comma'>,</span> <span class='symbol'>:mhtml</span><span class='comma'>,</span> <span class='id identifier rubyid_mtime'>mtime</span><span class='rparen'>)</span>
      <span class='kw'>end</span>
    <span class='kw'>end</span>
  <span class='kw'>end</span>
<span class='kw'>end</span></pre>
    </td>
  </tr>
</table>
</div>
    
  </div>

</div>

    <div id="footer">
  Generated on Wed Oct 28 12:19:04 2015 by
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
  0.8.7.6 (ruby-2.1.3).
</div>

  </body>
</html>